home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
ead
/
ead28.dms
/
ead28.adf
/
Listati
/
sm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-10
|
4KB
|
184 lines
/* ***********************************************************************
Programma ........ ScreenShift
Autore ........... Anson Mah, adattamento a 5.04 di Olli
Versione ......... 1.0, 4 giugno 1987
Funzione ......... Centratura dello schermo via gadget
Compilazione ..... LC -vbr -cusfi -O -Lntv ScreenShift.c
Note ............. Traduzione e revisione per V5.10 di Luigi Callegari
************************************************************************ */
#include <intuition/intuition.h>
#ifdef LATTICE
# include <proto/intuition.h>
# include <proto/exec.h>
#else
# include <functions.h>
#endif
#define PROPGADWIDTH 200 /* Gadget propozionale */
#define PROPGADHEIGHT 50
#define XJUMP 512
#define YJUMP 1024
#define UP 0x4c
#define DOWN 0x4d
#define LEFT 0x4f
#define RIGHT 0x4e
#define CR 0x44 /* Tasto RETURN */
extern UWORD xoffset(BYTE), yoffset(BYTE); /* Le routines di Math.asm */
extern BYTE xpot(UWORD), ypot(UWORD);
UWORD piData[60] = {
0x0000,0x0000,0x0000,
0x7FFF,0xFFFF,0xFE00,
0x7FFF,0xB7DF,0xFE00,
0x7FFB,0xDBDF,0xFE00,
0x7FFD,0xFDDF,0xFE00,
0x7FFF,0xDADF,0xFE00,
0x7FFB,0xDBDF,0xFE00,
0x7FFF,0xBBDF,0xFE00,
0x7FFF,0xFFFF,0xFE00,
0x0000,0x0000,0x0000,
0xFFFF,0xFFFF,0xFF00,
0xFFFF,0xFFFF,0xFF00,
0xFFF0,0x6FBF,0xFF00,
0xFFE7,0x273F,0xFF00,
0xFFE3,0xE23F,0xFF00,
0xFFFE,0x253F,0xFF00,
0xFFE7,0x273F,0xFF00,
0xFFF0,0x673F,0xFF00,
0xFFFF,0xFFFF,0xFF00,
0xFFFF,0xFFFF,0xFF00
};
struct Image piImage = {
0, 0, /* LeftEdge, TopEdge */
40, 10, 2, /* Width, Height, Depth */
&piData[0], /* ImageData */
0x03, 0x00, /* PlanePick, PlaneOnOff */
NULL /* NextImage */
};
struct PropInfo pinfo = {
FREEVERT | FREEHORIZ,
0,0, MAXBODY/5,MAXBODY/5,
0,0,0,0,0
};
struct Gadget pgadget = {
NULL, 0, 10, PROPGADWIDTH, PROPGADHEIGHT, GADGIMAGE, FOLLOWMOUSE,
PROPGADGET, (APTR)&piImage, NULL, NULL, 0, (APTR)&pinfo,
0, NULL
};
struct NewWindow pwindef = {
220, 70,
PROPGADWIDTH, PROPGADHEIGHT + 10,
0, 3,
CLOSEWINDOW | MOUSEMOVE | RAWKEY,
WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | ACTIVATE | SMART_REFRESH | RMBTRAP,
&pgadget,
NULL,
"ScreenMove",
NULL, NULL,
0,0, 0,0,
WBENCHSCREEN
};
void _main( void );
void XCEXIT( int );
void _main( void )
{
struct IntuiMessage *msg;
ULONG class, code;
BYTE c_xoffset, c_yoffset;
struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 33);
struct Preferences pref;
struct Window *pwin;
/* Legge preferenze attuali */
(void)GetPrefs(&pref, sizeof(struct Preferences));
/* Fissa gadget proporzionale per setting di View attuali */
pinfo.HorizPot = xoffset(pref.ViewXOffset);
pinfo.VertPot = yoffset(pref.ViewYOffset);
if (!(pwin = (struct Window *)OpenWindow(&pwindef)))
goto exit;
for (;;) {
WaitPort( pwin -> UserPort );
msg = (struct IntuiMessage *) GetMsg(pwin -> UserPort);
class = msg -> Class;
code = msg -> Code;
ReplyMsg( (struct Message *) msg );
switch ( class ) {
case CLOSEWINDOW:
goto exit;
case RAWKEY:
switch (code) {
case UP:
if (pinfo.VertPot >= YJUMP)
pinfo.VertPot -= YJUMP;
else pinfo.VertPot = 0;
break;
case DOWN:
if (pinfo.VertPot < MAXBODY - YJUMP)
pinfo.VertPot += YJUMP;
else pinfo.VertPot = MAXBODY;
break;
case LEFT:
if (pinfo.HorizPot >= XJUMP)
pinfo.HorizPot -= XJUMP;
else pinfo.HorizPot = 0;
break;
case RIGHT:
if (pinfo.HorizPot < MAXBODY - XJUMP)
pinfo.HorizPot += XJUMP;
else pinfo.HorizPot = MAXBODY;
break;
case CR: /* carriage return */
goto exit;
}
RefreshGadgets(&pgadget, pwin, NULL);
case MOUSEMOVE:
c_xoffset = xpot(pinfo.HorizPot);
c_yoffset = ypot(pinfo.VertPot);
if (pref.ViewXOffset != c_xoffset || pref.ViewYOffset != c_yoffset) {
pref.ViewXOffset = c_xoffset;
pref.ViewYOffset = c_yoffset;
(void)SetPrefs(&pref, sizeof(struct Preferences), FALSE);
}
break;
}
}
exit:
if( pwin )
CloseWindow(pwin);
XCEXIT(0);
}